package main

func main() {

	s := "{[]}"
	println(isValid(s))
}

func isValid(s string) bool {

	if len(s) <= 1 {
		return false
	}

	if len(s)%2 != 0 {
		return false
	}

	stack := make([]rune, 0)

	for _, v := range s {
		if len(stack) == 0 {
			stack = append(stack, v)
			continue
		}
		if isEqualChar(stack[len(stack)-1], v) {
			stack = stack[:len(stack)-1]
			continue
		}

		stack = append(stack, v)

	}

	return len(stack) == 0
}

func isEqualChar(a rune, b rune) bool {

	if a == '{' && b == '}' {
		return true
	}

	if a == '[' && b == ']' {
		return true
	}

	if a == '(' && b == ')' {
		return true
	}

	return false
}
